const obj = {
  count: 0,
  /* 普通函数调用 */
  print: function () {
    const that = this; //这里的this指向obj
    setInterval(function () {
      //   console.log(this); //this指向全局对象window
      console.log(that.count); //利用作用域that绑定obj
    }, 500);
  },
  /* 箭头函数的this和调用无关，与定义的位置有关 */
  print1: function () {
    setInterval(() => {
      console.log(this.count);
    }, 500);
  },
  /* 对象里面直接打印this，指向全局 */
  print2: () => {
    console.log(this.count);
  },
  regEvent: function () {
    window.onclick = () => {
      this.count
    }
  }
};

obj.print(); 0
obj.print1(); 0
const result = obj.print1
result()         //this指向window undefined
obj.print2();   //this指向window undefined
obj.regEvent();   //this指向window undefined


